using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

using SharpCore.Data;

namespace TF.Access {
	public partial class Tf_log_type {
		#region Fields
		private string log_type;
		private string log_type_desc;
		private string log_display_template;
		#endregion
		
		#region Constructors
		/// <summary>
		/// Initializes a new instance of the Tf_log_type class.
		/// </summary>
		public Tf_log_type() {
		}
		
		/// <summary>
		/// Initializes a new instance of the Tf_log_type class.
		/// </summary>
		public Tf_log_type(string log_type, string log_type_desc, string log_display_template) {
			this.log_type = log_type;
			this.log_type_desc = log_type_desc;
			this.log_display_template = log_display_template;
		}
		#endregion
		
		#region Properties
		/// <summary>
		/// Gets or sets the Log_type value.
		/// </summary>
		public string Log_type {
			get { return log_type; }
			set { log_type = value; }
		}
		
		/// <summary>
		/// Gets or sets the Log_type_desc value.
		/// </summary>
		public string Log_type_desc {
			get { return log_type_desc; }
			set { log_type_desc = value; }
		}
		
		/// <summary>
		/// Gets or sets the Log_display_template value.
		/// </summary>
		public string Log_display_template {
			get { return log_display_template; }
			set { log_display_template = value; }
		}
		#endregion
		
		#region Methods
		/// <summary>
		/// Saves a record to the tf_log_type table.
		/// </summary>
		public void Insert() {
			SqlClientUtility.ExecuteNonQuery("tf_log_typeInsert", log_type, log_type_desc, log_display_template);
		}
		
		/// <summary>
		/// Updates a record in the tf_log_type table.
		/// </summary>
		public void Update() {
			SqlClientUtility.ExecuteNonQuery("tf_log_typeUpdate", log_type, log_type_desc, log_display_template);
		}
		
		/// <summary>
		/// Deletes a record from the tf_log_type table by its primary key.
		/// </summary>
		public void Delete() {
			SqlClientUtility.ExecuteNonQuery("tf_log_typeDelete", log_type);
		}
		
		/// <summary>
		/// Selects a single record from the tf_log_type table.
		/// </summary>
		public static Tf_log_type Select(string log_type) {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("tf_log_typeSelect", log_type)) {
				if (dataReader.Read()) {
					return MakeTf_log_type(dataReader);
				} else {
					return null;
				}
			}
		}
		
		/// <summary>
		/// Selects all records from the tf_log_type table.
		/// </summary>
		public static List<Tf_log_type> SelectAll() {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("tf_log_typeSelectAll")) {
				List<Tf_log_type> tf_log_typeList = new List<Tf_log_type>();
				while (dataReader.Read()) {
					Tf_log_type tf_log_type = MakeTf_log_type(dataReader);
					tf_log_typeList.Add(tf_log_type);
				}
				return tf_log_typeList;
			}
		}
		
		/// <summary>
		/// Creates a new instance of the tf_log_type class and populates it with data from the specified SqlDataReader.
		/// </summary>
		private static Tf_log_type MakeTf_log_type(SqlDataReader dataReader) {
			Tf_log_type tf_log_type = new Tf_log_type();
			
			if (dataReader.IsDBNull(0) == false) {
				tf_log_type.Log_type = dataReader.GetString(0);
			}
			if (dataReader.IsDBNull(1) == false) {
				tf_log_type.Log_type_desc = dataReader.GetString(1);
			}
			if (dataReader.IsDBNull(2) == false) {
				tf_log_type.Log_display_template = dataReader.GetString(2);
			}

			return tf_log_type;
		}
		#endregion
	}
}
